Recording apparatuses having a recording medium such as a semiconductor memory, magnetic disk, magneto-optical disk, and an optical disk have been widely used as recording apparatuses for recording information in computer systems such as personal computers.
If data is recorded on a recording apparatus capable of random access such as a hard disk drive (HDD) which uses a magnetic disk as its recording medium, the data is not recorded in contiguous areas on the recording medium, but instead, is recorded in clusters, which are the smallest recording units. In the recording apparatus, a file system is used in which a directory entry containing file names and the cluster number of the first piece of data scattered in pieces in the recording apparatus and a file allocation table (FAT) which identifies the order of the pieces of scattered data are used to manage files recorded on the recording apparatus.
A file system which has been used for managing files recorded on such a recording apparatus will be described below.
FIG. 7 shows a configuration of a FAT file system. As shown in FIG. 7, provided in a recording apparatus is a file system including directory entries 701 of a root directory, which are information containing the filenames of recorded files and the starting cluster number of scattered data, clusters 703 which are the smallest recording units for storing real data, and a FAT 702 indicating information about the links between clusters 703 constituting a file. In the example shown in FIG. 7, the directory entry 701 indicates that a file, Data 1, is stored in clusters starting with cluster number 0002 on this recording apparatus. The FAT 702 indicates that the data in Data 1 is arranged in the order of cluster numbers 0002, 0003, and 0004 and the real data in Data 1 is recorded in the areas associated with cluster numbers 0002, 0003, and 0004 of the clusters 703. The FAT 702 also indicates that another file, Data 2 is stored only in the area associated with cluster number 0006.
When a file is created in the recording apparatus, its filename and the starting cluster number are entered in a directory entry 701 of the root directory and information about the links between clusters 703 in the FAT 702 is updated as real data is recorded in each area of the clusters 703. When a file is deleted from the recording apparatus, a portion corresponding to the file to be deleted from the directory entry 701 is set as “Unused” and the link information in the FAT 702 is set as unused in the order in which the clusters are linked.
In this way, each time a file operation is performed on the recording apparatus, the FAT 702 and a directory entry 701 are updated. Therefore, if a power failure causes a file operation to be aborted without performing a normal procedure, the FAT 702 and the directory entry 701 are corrupted, resulting in file corruption and data loss.
In a FAT file system, two file allocation tables 702 with the same size are originally provided so that, in the event that one of them is corrupted, data can be copied from the other to recover file information. The directory entry 701, on the other hand, is not duplicated. Accordingly, in case the directory entry 701 is corrupted, a corrupted file or lost data can never be recovered.
Therefore, a data recovery method as disclosed in Japanese Patent Laid-Open No. 2002-63057 (paragraphs [0001] and [0002] and FIGS. 4 and 5) has been proposed for enabling data to be recovered even if a directory entry 701 is corrupted. In that method, a temporary index as shown in FIG. 8 is created and recorded in a recording apparatus before a directory entry and a FAT are updated and, once an update of the directory entry and the FAT has been completed successfully, the temporary index is deleted from the recording apparatus.
In FIG. 8, reference number 801 denotes a sector number indicating a recording location in the directory entry 701 in the recording apparatus and 802 denotes a flag indicating whether the directory entry 701 and the FAT 702 are being updated. The remaining information items are information originally contained in the directory entry 701.
In the vent a file operation is aborted due to a power failure for example, determination is made during restarting as to whether a temporary index is present or not. If a temporary index is found, data in the temporary index is compared with its corresponding data in the directory entry 701 for recovering the directory entry 701.
According to such a prior-art data recovery method, an abort of a write of data about the size of one sector to a recording apparatus is neglected because of its smallness. This method has a problem that, if a write operation is aborted due to a power failure for example, the temporary index cannot successfully be read during restarting and therefore a recovery process cannot be performed, because determination as to whether or not a recovery process should be performed is made based on a flag in the temporary index.
Another problem with the method is that the temporary index is deleted after a successful update of a directory entry for recovering data and therefore, if file operations are frequently performed, temporary index delete operations are also performed frequently and thus time spent for file update processing is increased.